<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>

    // i>=1    fn(n) = n + fn(n-1);  // 
    // i = 1   fn(1) = 1;

    // fn(5) = 1 + 2 + 3 + 4 + 5 ;      fn(5) = 5 + fn(4)
    // fn(4) = 1 + 2 + 3 + 4 ;          fn(4) = 4 + fn(3)
    // fn(3) = 1 + 2 + 3 ;              fn(3) = 3 + fn(2)
    // fn(2) = 1 + 2 ;                  fn(2) = 2 + fn(1)
    // fn(1) = 1 ;                      fn(1) = 1

    // 依赖性递归   每个函数的结果 依赖于 前一个或多个的结果
    function fn(n){
        if(n == 1) {
            return 1;
        }
        return n + fn(n-1);
    }

    // fn(5) => 5 + fn(4) =>  4 + fn(3) => 3 + fn(2) =>  2 + fn(1)
    //                                                        ||
    //  15  <=  5  +  10  <=   4   + 6  <=   3 +   3  <=  2 +  1


    


</script>
</html>